//
//  KXTabBarViewController.swift
//  KXBook
//
//  Created by  on 2022/9/7.
//

import UIKit

class KXTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self
        self.setupColor()
        self.setupViewController()
    }
    
    func setupColor()
    {
        self.tabBar.isTranslucent = false
        self.tabBar.tintColor = "#E27BC1".color()
        self.tabBar.unselectedItemTintColor = "#969696".color()
        self.tabBar.backgroundImage = UIImage.withColor(UIColor.white)
        self.tabBar.backgroundColor = .white
    }
    
    func setupViewController()
    {
        let controllers = [KXHomeViewController(), KXMeViewController()]
        let titles = ["明细","我的"]
        let imgs = ["组 79","组 77"]
        let selectImgs = ["组 78","组 80"]
        for i in 0..<controllers.count{
            let vc = controllers[i]
            vc.tabBarItem = UITabBarItem()
            vc.tabBarItem.title = LS(titles[i])
            vc.tabBarItem.image = UIImage(named:imgs[i])?.withRenderingMode(.alwaysOriginal)
            vc.tabBarItem.selectedImage = UIImage(named:selectImgs[i])?.withRenderingMode(.alwaysOriginal)
            let nav = KXNavigationViewController(rootViewController:vc)
            self.addChild(nav)
        }
    }

}
extension KXTabBarViewController: UITabBarControllerDelegate
{
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        return true
    }
}
